const connection = require("../app/database");

class AuthService {
	async checkResource(resourceName, resourceId, userId) {
		try {
			const statement = `SELECT * FROM ${resourceName} WHERE id = ? AND user_id = ?`;
			const [result] = await connection.execute(statement, [
				resourceId,
				userId
			]);
			return !!result.length;
		} catch (error) {
			console.log(error);
		}
	}
}

module.exports = new AuthService();
